<template>
    <div>
        <h1>会员权益</h1>
        <input type="button" value="增加权益" class="btn btn-success" @click="add">
      名称  <input type="text" v-model="queryInfo.Name"/>
      <input type="button" value="查询" @click="gitshow"/>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td>权益名称</td>
                    <td>权益状态</td>
                    <td>权益备注</td>
                    <td>创建时间</td>
                    <td>修改时间</td>
                    <td>操作</td>
                </tr>
                <tr v-for="item in data.List" :key="item.Id">
                    <td>{{ item.Name }}</td>
                    <td>{{ item.State==1?'是':'否' }}</td>
                    <td>{{ item.Desc }}</td>
                    <td>{{ item.CreateTime.substring(0,7) }}</td>
                    <td>{{ item.UpdateTime.substring(0,7) }}</td>
                    <td>
                        <input type="button" value="删除"/>
                        <input type="button" value="修改"/>
                    </td>
                </tr>
            </tbody>
        </table>
        <span>总共{{ data.totalCount }}条</span>
        <span>总共{{ data.totalCount }}条</span>
        <span>当前{{ queryInfo.pageindex }} /{{queryInfo.pageSize}}页</span>
        <input type="button" value="首页" @click="ye(1)"/>
        <input type="button" value="上一页" @click="ye(queryInfo.pageindex -1)"/>
        <input type="button" value="下一页" @click="ye(queryInfo.pageindex +1)"/>
        <input type="button" value="尾页" @click="ye(data.totalPage)"/>
        <input type="text" v-model="queryInfo.pageindex"/>
        <input type="button" value="跳转" @click="ye(queryInfo.pageindex)"/>
        <select v-model="queryInfo.pageSize" @change="show">
            <option :value="item" v-for="item in arr" :key="item">
                {{ item }}
            </option>
        </select>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';

import { ref,reactive,onMounted } from 'vue';
import { useRouter } from 'vue-router';
const router=useRouter();
const add=()=>{
    router.push('/userRihtAdd');
}
let arr=ref([2,4,6,8]);
const show = () => {
  queryInfo.pageIndex = 1;
  gitshow();
};

let queryInfo:any=reactive({
      Name: '',
      State:0 ,
      Desc: '',
      CreateTime: "2024-11-18T16:45:32.3340006",
      UpdateTime: "2024-11-18T16:45:32.3340018",
      pageindex:1,
      pageSize:2
});
let data:any=reactive({
    List:[],
    totalCount:0,
    totalPage:0,
});
onMounted(() => {
    gitshow();
});


const gitshow=()=>{
    axios({
        url:'/api/ZMember/ZUserRights',
        method:'get',
        params:queryInfo
    })
    .then((res)=>{
        console.log(res);
        data.List=res.data.List;
        data.totalCount=res.data.totalCount;
        data.totalPage=res.data.totalPage;
        
    })
    .catch((err)=>{
        console.log(err);
    })
}
const ye=(num:any)=>{
  
  if(num<1){
      queryInfo.pageindex=1;
      return;
  }
  if(num>data.totalPage){
      queryInfo.pageindex=data.totalPage;
      return;
  }
  queryInfo.pageindex = num;
  gitshow();
};
</script>

<style scoped>

</style>